/*
 * FileName: StaffDailyService.java
 *
 */
package com.mrc.ak.daily.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mrc.ak.daily.dao.DailyInfoDao;
import com.mrc.ak.daily.model.DailyInfo;
import com.mrc.core.base.Constant;
import com.mrc.core.base.PageDatas;
import com.mrc.core.model.SysUser;

/**
 * <p>
 * Description: 
 * </p>
 *
 * @author Mrc
 * @version 4.1

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2016-12-22 上午10:17:42          Mrc        4.1         To create
 * </p>
 *
 * @since 
 * @see     
 */
@Service
@Transactional
public class DailyInfoService {

    @Autowired
    private DailyInfoDao staffDailyDao;

    /**
     * 员工保存日报
     * @param user 
     * @param dailyContent
     * @param type
     * @param dealStatus 
     * @param remark
     */
    public void saveDaily(SysUser user, String dailyContent, Integer type, Integer dealStatus, String remark) {
        DailyInfo dailyInfo = new DailyInfo();
        dailyInfo.setContent(dailyContent);
        dailyInfo.setDate(new Date());
        dailyInfo.setRemark(remark);
        dailyInfo.setType(type);
        dailyInfo.setUserCode(user.getMobile());
        dailyInfo.setUserId(user.getId());
        dailyInfo.setDealStatus(dealStatus);
        dailyInfo.setVerifyStatus(Constant.DAILY_STATUS_UNVERIFY);
        staffDailyDao.save(dailyInfo);
    }

    /**
     * 按照条件查询 
     * @param date  2016-12-22 或者  2016-12-21至2016-12-22
     * @param verifyStatus
     * @param type
     * @return
     */
    public PageDatas query(String date, String verifyStatus, Integer type, Integer pageNo, Integer pageSize) {
        PageDatas pageDatas = staffDailyDao.query(date, verifyStatus, type, pageNo, pageSize);
        return pageDatas;
    }

}
